package com.example.mymultiactivityapp

import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText

class SecondActivity2 : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second2)

        val etInput = findViewById<EditText>(R.id.et_input)
        findViewById<Button>(R.id.btn_confirm).setOnClickListener {
            val result = etInput.text.toString()
            val returnIntent = Intent().apply {
                putExtra("return_data", result)
            }
            setResult(Activity.RESULT_OK, returnIntent)
            finish()
        }
    }
}